package com.yaolong.api.modules.gen.service.impl;

import com.yaolong.commons.base2.BaseServiceImpl;
import com.yaolong.api.modules.gen.model.entity.DataSource;
import com.yaolong.api.modules.gen.dao.DataSourceDao;
import com.yaolong.api.modules.gen.service.IDataSourceService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 * <p>
 * 数据源配置表 服务实现类
 * </p>
 *
 * @author yaolonga
 * @since 2022-12-30
 */
@Service
public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSource> implements IDataSourceService {
    @Override
    public IPage<DataSource> page(int current, int size, DataSource domain) {

        IPage<DataSource> page = new Page<>(current, size);

        return lambdaQuery()
                .eq(!ObjectUtils.isEmpty(domain.getDbPassword()), DataSource::getDbPassword, domain.getDbPassword())
                .page(page);
    }

}
